package com.zzy.redis.test;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class RedisStringJava {
    public static void main(String[] args) {

        //连接本地的 Redis 服务
        String url = "192.168.125.130";//localhost
        //Jedis jedis = new Jedis(url,6379);// http://192.168.125.130/
        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        JedisPool jedisPool = new JedisPool(poolConfig,url, 6379, 100000,"zzy");//给redis设置了密码zzy
        Jedis jedis = jedisPool.getResource();


        System.out.println("连接成功");
        //设置 redis 字符串数据
        jedis.set("zzy", "张小凡");
        // 获取存储的数据并输出
        System.out.println("redis 存储的字符串为: "+ jedis.get("zzy"));
    }
}